package org.example.day;

import com.sun.deploy.util.StringUtils;

import java.util.HashSet;

/**
 * @Description: TODO
 * @Author wyatt
 * @Data 2024/06/24 21:17
 */
public class Solution3 {

    public static void main(String[] args) {
        System.out.println(new Solution3().lengthOfLongestSubstring("abcabcbb"));
    }
    public int lengthOfLongestSubstring(String s) {
        if(s.length() == 0){
            return 0;
        }
        int ans = 1;
        HashSet<Character> set = new HashSet<>();

        for(int i = 0;i<s.length();i++){
            String str = s.substring(i);
            for (Character c : str.toCharArray()) {
                if(set.contains(c)){
                    break;
                }
                set.add(c);
            }
            ans = Math.max(ans, set.size());
            set = new HashSet<>();
        }
        return ans;
    }
}
